#pragma once
#include <iostream>
#include "Protocol.hpp"

using namespace protocol_ns;

class Calculate
{
    public:
    Calculate()
    {}
    Response Excute(const Request &req)
    {
        Response res(0,0);
        switch (req._oper)
        {
        case '+':
            res._result = req._x+req._y;
            break;
        case '-':
        res._result = req._x-req._y;
        break;
        case '*':
        res._result = req._x*req._y;
        break;
        case '/':
        if(req._y==0)
        {
            res._code = 2;
        }
        else
        {
            res._result = req._x/req._y;
        }
        break;
        case '%':
        res._result = req._x%req._y;
        break;
        default:
            res._code = 3;
            break;
        }
        return res;
    }
};
